package com.woke.method;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.Header;
import org.json.JSONException;
import org.json.JSONObject;

import android.util.Log;

import com.http.HttpMethods;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.JsonHttpResponseHandler;
import com.loopj.android.http.RequestParams;

public class Httpfgetdata {
	private static String str_result;
	public static String getdataresu(){
		AsyncHttpClient ahc = new AsyncHttpClient();
		RequestParams params = new RequestParams();
		params.put("g", "api");
		params.put("m", "Ads");
		params.put("a", "adsList");
		ahc.get(HttpMethods.BASEURL, params, new JsonHttpResponseHandler(){
			
			@Override
			public void onSuccess(int statusCode, Header[] headers,
					JSONObject response) {
				super.onSuccess(statusCode, headers, response);
				Log.e("请求的数据", "请求的数据"+response);
				try {
					String flag = response.getString("flag");
					JSONObject jsonObject = response.getJSONObject("data");
					if(flag.equals("success")){
						str_result = jsonObject.getString("data");
//						return str_result;
//						ArrayList<Data_address> parseArray = (ArrayList<Data_address>) JSONArray.parseArray(str_result, Data_address.class);
					}
				} catch (JSONException e) {
					e.printStackTrace();
				}
				
			}
			
			@Override
			public void onFailure(int statusCode, Header[] headers,
					String responseString, Throwable throwable) {
				super.onFailure(statusCode, headers, responseString, throwable);
				Log.e("string", responseString);
			}
			
			@Override
			public void onStart() {
				// TODO Auto-generated method stub
				super.onStart();
			}
			
			@Override
			public void onFinish() {
				super.onFinish();
				
				
			}
		});
		return null;
		
	}
}
